package cn.topcodes.tcsf.cms.service;

import cn.topcodes.tcsf.cms.domain.entity.AlbumCatalog;
import cn.topcodes.tcsf.cms.domain.entity.ProductionTag;
import cn.topcodes.tcsf.admin.commons.generic.GenericService;
import cn.topcodes.tcsf.cms.domain.vo.NestableSort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ProductionTag 服务
 *
 * @author Yvan
 * @date 2018-02-09 10:46:47
 */
@Service
public class ProductionTagService extends GenericService<ProductionTag> {

    @Transactional(readOnly = false, rollbackFor = Exception.class)
    public void saveSort(List<NestableSort> sort) {
        if (sort == null) return;
        for (int i = 0; i < sort.size(); i++) {
            NestableSort s = sort.get(i);
            ProductionTag productionTag = this.findOne(s.getId());
            productionTag.setSort(i);
            this.update(productionTag);
        }
    }
}
